﻿//------------------------------------------------------------------------------
// <copyright file="Utilities.cs" company="CommerceServer.net, Inc">
//    (c) 2012 CommerceServer.net, Inc. and its affiliates. All rights reserved.
// </copyright>
// <summary></summary>
//------------------------------------------------------------------------------ 
namespace CommerceServerContrib.CodeGeneration
{
    using System;
    using System.Globalization;

    public static class Utilities
    {
        public static string CleanName(string name)
        {
            while (name.IndexOf("_", StringComparison.OrdinalIgnoreCase) > -1)
            {
                var index = name.IndexOf("_", StringComparison.OrdinalIgnoreCase);

                if ((index + 1) != name.Length && name[index + 1].ToString() != "_")
                {
                    name = name.Remove(index + 1, 1).Insert(index + 1, name[index + 1].ToString().ToUpper(CultureInfo.InvariantCulture));
                }

                name = name.Remove(index, 1);
            }

            name = name.Replace(".", string.Empty);

            return name;
        }
    }
}
